package com.pshare.artemis.common.tool;

import com.aliyun.oss.OSSClient;

/**
 * 阿里云文件上传
 * 
 * @author 等待
 */
public class UpAliYunUploadTool {
	// 运行前先设置好以下三个参数
		private static final String BUCKET_NAME = "bx-imgs";
		private static final String ACCESS_KEY_ID = "QlRjibXTLzqXsoHQ";
		private static final String ACCESS_KEY_SECRET = "zskdIkbARpzElOMkidUJB4hbOhJGAV";
		private static OSSClient client=null;
		
		/** 绑定的域名 */
		private static final String URL = "http://oss-cn-hangzhou.aliyuncs.com";
		/** bucket的域名 */
		private static final String DOMAINURL = "http://bx-imgs.oss-cn-hangzhou.aliyuncs.com";

		/** 根目录 */
		private static final String DIR_ROOT = "/";
		//获取链接对象
		public static OSSClient getOSSClient(){
			if(client==null){
				client=new OSSClient(URL,ACCESS_KEY_ID,ACCESS_KEY_SECRET);
			}
			return client;
		}
		
		public static String getKey(){
			return ACCESS_KEY_ID;
		}
		
		public static String getDomianUrl(){
			return DOMAINURL;
		}
		
		public static String getBuckName(){
			return BUCKET_NAME;
		}
		public static void creatBuckName(String name){
			client.createBucket(name);
		}
}
